# Untitled - By: 64386 - Thu Feb 8 2024

import sensor, image, time, math

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)

clock = time.clock()
d0 = []
d1 = []
d2 = []
d3 = []
flag_zuobiao = 0
while(True):
    clock.tick()
    img = sensor.snapshot()

    #畸变矫正
    img = sensor.snapshot().lens_corr(strength = 1.5, zoom = 1.0)
    #strength是畸变矫正的主要参数，zoom是大小的参数

       # 下面的`threshold`应设置为足够高的值，以滤除在图像中检测到的具有
       # 低边缘幅度的噪声矩形。最适用与背景形成鲜明对比的矩形。


    for r in img.find_rects(threshold = 10000):

        for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 0, 255))  #在四个角上画圆圈标记
        #print(r)
        #print(r.corners())
        i = r.corners()
        while flag_zuobiao < 1:
            d0.append(i[0])
            d1.append(i[1])
            d2.append(i[2])
            d3.append(i[3])
            print(d0)
            print(d1)
            print(d2)
            print(d3)
            flag_zuobiao = flag_zuobiao + 1
        time.sleep(1)

        # print("FPS %f" % clock.fps())
    #print(clock.fps())
